#ifndef _PRINTFINFO_H
#define _PRINTFINFO_H

#include <iostream>
#include <string>
#include <fstream>
#include <time.h>

#include <stdio.h>
#include <stdlib.h>

#ifndef DEBUG
	#define DEBUG
#endif

#ifdef DEBUG
	#define DEBUG_INFO printf("\nDEBUG:info: file:%s, line:%d, function:%s\n    ", __FILE__, __LINE__, __FUNCTION__);printf
#else
	#define DEBUG_INFO /\
/ printf
#endif

#define PRINTINFO printf("\nfile:%s, line:%d, function:%s\n\033[1;32mINFO:\033[0m     ", __FILE__, __LINE__, __FUNCTION__);printf
#define WARNING printf("\nWARNING INFO:  file:%s, line:%d, function:%s  \033[1;35mwarning:\033[0m ", __FILE__, __LINE__, __FUNCTION__);printf
#define ERRORINFO printf("\nERROR INFO:  file:%s, line:%d, function:%s  \033[1;31merror:\033[0m ", __FILE__, __LINE__, __FUNCTION__);printf


#if 0
namespace LOGGER{

//debug   info   warning   error
class Loger{
public:
	Loger();
	Loger(const string saveLogFilePath, const bool printDebugInfo, const bool writeFile);
	~Loger();
	std::string m_currTime();

	enum m_log_level{debug, info, warning, error};
	enum m_log_target{file, terminal, fileAndTerminal};

protected:

private:
	std::ofstream m_ofs;
	m_log_target m_target;
	m_log_level m_level;
	std::string m_logPath;
	bool m_printDebugInfo;
	bool m_writeFile;

	void m_DEBUG(std::string text);
	void m_INFO(std::string text);
	void m_WARNING(std::string text);
	void m_ERROR(std::string text);

};
Loger::Loger():m_target(terminal),
			m_level(debug)
{
	printf("WELCOME %s, currTime: %s : === start logging ===", __FILE__, m_currTime().c_str());

}
Loger::Loger(const string saveLogFilePath, const bool printDebugInfo, const bool writeFile):
			m_target(terminal),
			m_level(debug),
			m_printDebugInfo(printDebugInfo),
			m_writeFile(writeFile)
{
	m_ofs.open(saveLogFilePath, ios::out | ios::app);
	printf("WELCOME %s, currTime: %s : === start logging ===", __FILE__, m_currTime().c_str());

	if(!writeFile){
		m_ofs.close();
	}
}
Loger::~Loger()
{
	if(m_writeFile){
		m_ofs.close();
	}
}
void Loger::m_DEBUG(std::string text)
{
	printf("DEBUG:info: file:%s, line:%d, function:%s\n    ", __FILE__, __LINE__, __FUNCTION__);
	printf("%s\n", text.c_str());
}
void Loger::m_INFO(std::string text)
{
	printf("file:%s, line:%d\n\033[1;32mINFO:\033[0m     ", __FILE__, __LINE__);
	printf("%s\n", text.c_str());
}
void Loger::m_WARNING(std::string text)
{
	printf("DEBUG:warning: file:%s, line:%d, function:%s\n    ", __FILE__, __LINE__, __FUNCTION__);
	printf("%s\n", text.c_str());
}
void Loger::m_ERROR(std::string text)
{
	printf("ERROR INFO:  file:%s, line:%d, function:%s  \033[1;31merror:\033[0m ", __FILE__, __LINE__, __FUNCTION__);
	printf("%s\n", text.c_str());
}

std::string Loger::m_currTime()
{
	char tmp[64];
	time_t ptime;
	time(&ptime);
	strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&ptime));
	return tmp;
}

}
#endif

#endif